package com.meedoll.manager.std.client.logon;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.PopupPanel;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.Widget;
import com.meedoll.manager.std.client.mainpanel.composites.MainPanelUI;

public class LogonPanelUI extends PopupPanel {

	private static final Binder binder = GWT.create(Binder.class);
	@UiField
	Button button;

	interface Binder extends UiBinder<Widget, LogonPanelUI> {
	}

	public LogonPanelUI() {
		setWidget(binder.createAndBindUi(this));

	}

	@UiHandler("button")
	void onButtonClick(ClickEvent event) {
		RootPanel.get("MainContainer").clear();
	
		ILogonServiceAsync logons = GWT.create(ILogonService.class);
		logons.existUser("james", "james", new AsyncCallback<LogonBean>() {
			@Override
			public void onFailure(Throwable caught) {

				System.out.println("erro==>" + caught.getMessage());

			}

			@Override
			public void onSuccess(LogonBean result) {
				if (result.isResult())
					RootPanel.get("MainContainer").add(new MainPanelUI());

				System.out.println("is ok");
			}
		});

	}
}
